import { createApp } from 'vue'
import { createPinia } from 'pinia'
import './style.css'
import App from './App.vue'
import router from './router'
import uploader from 'vue-simple-uploader'
import 'vue-simple-uploader/dist/style.css'
import { ElTable, ElTableColumn, ElPagination, ElMessage, ElDialog } from 'element-plus'
import * as ElIcons from '@element-plus/icons-vue'
import { useUserStore } from './store/user'
// import store from './store'
import 'normalize.css/normalize.css'
//  解决打包后Message等样式丢失问题 https://blog.csdn.net/Delete_89x/article/details/126430049
import 'element-plus/theme-chalk/el-loading.css'
import 'element-plus/theme-chalk/el-message.css'
import 'element-plus/theme-chalk/el-notification.css'
import 'element-plus/theme-chalk/el-message-box.css'


// 修改 el-dialog 默认点击遮照为不关闭
ElDialog.props.closeOnClickModal.default = false

const pinia = createPinia()
var app = createApp(App)

for (const [key, component] of Object.entries(ElIcons)) {
    app.component(key, component)
}

app.use(pinia)
app.use(ElPagination)
app.use(ElTable)
app.use(ElTableColumn)
app.use(ElMessage) // 全局注入影响速度
// app.use(store);
app.use(router).use(uploader).mount('#app')

// 初始化用户状态（从localStorage恢复）
const userStore = useUserStore()
userStore.initUserState()
// 测试环境变量
console.log(' import.meta.env.MODE: ', import.meta.env.MODE)
if (import.meta.env.VITE_PROXY_TARGET != undefined) {
    console.log(' import.meta.env.VITE_PROXY_TARGET: ', import.meta.env.VITE_PROXY_TARGET)
}
console.log(' import.meta.env.VITE_HELLO: ', import.meta.env.VITE_HELLO)
